package org.zgflex.desktop
{
	/**
	 * The iterator that iterates the array from the first element to the last
	 * @author dankok
	 * 
	 */		
	public class ArrayIterator implements IIterator {
      
		private var _index:uint = 0;
      	private var _collection:Array;

      	/**
      	 * Constructor 
      	 * @param collection The array to iterate
      	 * 
      	 */      			
      	public function ArrayIterator(collection:Array) {
      	 	if (collection) 
         		_collection = collection;
         	else 
         		_collection = new Array();
         	_index = 0;
      	}
		
		/**
      	 * @inheritDoc
      	 * 
      	 */	
      	public function hasNext():Boolean {
         	return _index < _collection.length;
      	}

		/**
      	 * @inheritDoc
      	 * 
      	 */	
      	public function next():Object {
         	return _collection[_index++];
      	}
		
		/**
      	 * @inheritDoc
      	 * 
      	 */	
      	public function reset():void {
         	_index = 0;
      	}
      	
      	/**
      	 * Not a part of the interface, but very handy 
      	 * @return 
      	 * 
      	 */      	
      	public function get count():uint {
      		return _collection.length;
      	}
   	}
}